<%--
    Document   : index
    Created on : Mar 6, 2011, 9:48:04 AM
    Author     : Vinh_Dragon
--%>

<%@page import="com.myapp.biz.SurveyBiz"%>
<%@page import="com.myapp.entities.Survey"%>
<%@page import="com.myapp.biz.QuestionBiz"%>
<%@page import="com.myapp.entities.Question"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
    <head>
        <title>Supper Survey</title>
        <meta charset="utf-8">
        <link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
        <link rel="stylesheet" href="css/grid.css" type="text/css" media="all">
        <link rel="stylesheet" href="css/style.css" type="text/css" media="all">
        <script type="text/javascript" src="js/jquery-1.4.2.min.js" ></script>
        <script type="text/javascript" src="js/cufon-yui.js"></script>
        <script type="text/javascript" src="js/Bell_Gothic_Std_500.font.js"></script>
        <script type="text/javascript" src="js/Bell_Gothic_Std_700.font.js"></script>
        <script type="text/javascript" src="js/cufon-replace.js"></script>
        <!--[if lt IE 7]>
  	<script type="text/javascript" src="http://info.template-help.com/files/ie6_warning/ie6_script_other.js"></script>
        <![endif]-->
        <!--[if lt IE 9]>
  	<script type="text/javascript" src="js/html5.js"></script>
        <![endif]-->
    </head>

    <body>
        <!-- header -->
        <%
                    HttpSession sess = request.getSession(true);
                    if (sess.getAttribute("username") == null) {
                        response.sendRedirect("login.jsp");
                    }
        %>
    <header>
        <div class="header-bg">
            <div class="container_24">
                <div class="logo">
                    <a href="index.html"><img src="images/logo.jpg" alt=""></a>
                </div>
                <nav>
                    <ul>
                        <li><a href="#" class="current">Home</a></li>
                        <li><a href="surveys.jsp">Create Survey</a></li>
                        <li><a href="questions.jsp">Create Question</a></li>                     
                        <li><a href="statistic.jsp">Statistic</a></li>
                        <li><a href="#">Contacts</a></li>
                    </ul>
                </nav>
                <a href="#" class="rss">RSS Submit</a>
                <a href="#" class="main-banner"><img src="images/main-banner.jpg" alt=""></a>
            </div>
        </div>
    </header>
    <!-- content -->
    <section id="content">
        <div class="container_24">
            <div class="row">
                <div class="wrapper">
                    <div class="grid_16">
                        <div class="box">
                            <!--Create survey-->
                            <html:form action="/createSurvey">
                                <table border="0" cellspacing="10">
                                    <thead>
                                        <tr style="height: 50px;">
                                            <th colspan="2"><h3>Create a Survey</h3></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr style="height: 40px;">
                                            <td>Survey's name: &nbsp;</td>
                                            <td><html:text property="name"></html:text></td>
                                        </tr>
                                        <tr>
                                            <td>Question: </td>
                                            <td>
                                                <html:select name="CreateSurveyFormBean" property="questionList">
                                                    <html:option value="Select a question" style="font-weight: bold;"></html:option>
                                                    <%
                                                                ArrayList<Question> list = new ArrayList<Question>();
                                                                QuestionBiz biz = new QuestionBiz();
                                                                list = biz.getListQuestion(this.getServletContext().getRealPath("/"));
                                                                for (int i = 0; i < list.size(); i++) {
                                                    %>
                                                    <html:option value="<%=list.get(i).getId()%>"></html:option>
                                                    <%
                                                                }
                                                    %>
                                                </html:select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <html:submit value="Create survey" property="mission">
                                                    <html:hidden value="1" property="mission"></html:hidden>
                                                </html:submit>
                                                <html:submit value="Delete question"  property="mission">
                                                    <html:hidden value="2" property="mission"></html:hidden>
                                                </html:submit>
                                                <html:submit value="Update question" property="mission">
                                                    <html:hidden value="3" property="mission"></html:hidden>
                                                </html:submit>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>

                            </html:form>
                        </div>

                        <div class="box">
                            <!--List of survey-->
                            <html:form action="/enableSurvey">
                                <table border="0" cellspacing="10">
                                    <thead>
                                        <tr style="height: 50px;">
                                            <th colspan="2"><h3>List of Surveys</h3></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>Surveys: </td>
                                            <td>
                                                <html:select name="CreateSurveyFormBean" property="surveyId">
                                                    <html:option value="Select a survey" style="font-weight: bold;"></html:option>
                                                    <%
                                                        ArrayList<Survey> surveys = new ArrayList<Survey>();
                                                        SurveyBiz sbiz = new SurveyBiz();
                                                        surveys = sbiz.getListSurvey(this.getServletContext().getRealPath("/"), "surveys.xml");
                                                        for (int i = 0; i < surveys.size(); i++) {
                                                    %>
                                                    <html:option value="<%=surveys.get(i).getSurveyId() + "-" +surveys.get(i).getSurveyName()%>"></html:option>
                                                    <%
                                                        }
                                                    %>
                                                </html:select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2"><html:submit value="Enable survey"></html:submit></td>
                                        </tr>
                                    </tbody>
                                </table>

                            </html:form>
                        </div>
                    </div>

                    <div class="grid_8">
                        <dl class="list2">
                            <dt><a href="questions.jsp">Create questions...</a></dt>
                            <dd>Create new questions.</dd>
                        </dl>

                    </div>
                </div>
            </div>
            <div class="row">
                <div class="wrapper">
                    <div class="grid_16">
                        <div class="wrapper p2">
                            <!--Phần nội dung chính của trang-->

                        </div>
                    </div>
                    <div class="grid_8">

                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- footer -->
    <footer>
        <div class="container_24">
            <div class="wrapper">
                <div class="copy">ABC Company &copy; 2010 &nbsp; | &nbsp; <a href="http://www.websitetemplates.org">Website Templates</a> designed by <a title="Free Templates Online" href="http://www.freetemplatesonline.com">FTO</a> </div>
                <nav>
                    <ul>
                        <li><a href="index.html" class="current">Home page</a></li>
                        <li><a href="index-1.html">About Us</a></li>
                        <li><a href="index-2.html">Solutions</a></li>
                        <li><a href="index-3.html">Clients</a></li>
                        <li><a href="index-4.html">FAQ</a></li>
                        <li><a href="index-5.html">Contacts</a></li>
                    </ul>
                </nav>
            </div>
        </div>
    </footer>
    <script type="text/javascript"> Cufon.now(); </script>
</body>
</html>

